
/****** Object:  StoredProcedure [dbo].[SFDA_attachment_firstSave]    Script Date: 07/27/2013 18:40:34 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE proc [dbo].[SFDA_attachment_firstSave]
@itemType nvarchar(50)='',
@workStation nvarchar(50)='',
@operator nvarchar(50)='',
@subID int
as
set nocount on

update T_attachmentInfoUse set correspondingNo = @subID 
where itemType = @itemType and workStation = @workStation and operator = @operator and correspondingNo = -1

update T_attachmentInfoUse set image_filename = title+'.'+reverse(substring(reverse(image_filename),1,charindex('.',reverse(image_filename)) - 1))
where itemType = @itemType and workStation = @workStation and operator = @operator and correspondingNo = @subID
select 1


--select top 1 * from T_attachmentInfoUse order by pk desc
GO

